class Handler
{
    private _successHandler:Handler;
    public set successHandler(successHandler:Handler)
    {
        this._successHandler = successHandler;
    }
    public get successor():Handler
    {
       return this._successHandler;
    }

    public handleRequest(message:number):void
    {}
}
class ConcreateHandleA extends Handler
{
    handleRequest(message:number):void
    {
        if(message > 0)
            {
                console.log("request handle by handleA");
            }else
            {
                if(this.successor != null)
                this.successor.handleRequest(message);
            }
    }
}

class ConcreateHandleB extends Handler
{
    handleRequest(message:number):void
    {
        if(message < 0)
            {
                console.log("request handle by handleB");
            }else
            {
                this.successor.handleRequest(message);
            }
    }
}
class ConcreatehandleC extends Handler
{
   
    handleRequest(message:number):void
    {
        if(message == 0)
            {
                console.log("request handle by handleC");
            }else {
                this.successor.handleRequest(message);
            }
    }
     
}

export class ChainOfResponsebilityAction
{
    test()
    {
        var handleA:ConcreateHandleA = new ConcreateHandleA();
        var handleB:ConcreateHandleB = new ConcreateHandleB();
        var handleC:ConcreatehandleC = new ConcreatehandleC();

        handleA.successHandler = handleB
        handleB.successHandler = handleC;
        handleA.handleRequest(0);
        handleA.handleRequest(1);
        handleA.handleRequest(-1);
    }
}
